﻿using Demo.Mmose.Core.Common.ThreadPool;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Win32.SafeHandles;
using System;
using System.Threading;

namespace Demo.Mmose.Core.Test
{
    /// <summary>
    ///这是 IOCompletionPortTest 的测试类，旨在
    ///包含所有 IOCompletionPortTest 单元测试
    ///</summary>
    [TestClass()]
    public class IOCompletionPortTest
    {
        private TestContext testContextInstance;
        /// <summary>
        ///获取或设置测试上下文，上下文提供
        ///有关当前测试运行及其功能的信息。
        ///</summary>
        public TestContext TestContext
        {
            get { return testContextInstance; }
            set { testContextInstance = value; }
        }

        #region 附加测试属性
        // 
        //编写测试时，还可使用以下属性:
        //
        //使用 ClassInitialize 在运行类中的第一个测试前先运行代码
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //使用 ClassCleanup 在运行完类中的所有测试后再运行代码
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //使用 TestInitialize 在运行每个测试前先运行代码
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //使用 TestCleanup 在运行完每个测试后运行代码
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion

        /// <summary>
        ///PostQueuedCompletionStatus 的测试
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Demo.Mmose.Core.dll" )]
        public void PostQueuedCompletionStatusTest()
        {
            SafeIOCompletionPortHandle_Accessor hIOCP = null; // TODO: 初始化为适当的值
            uint numBytesTransferred = 0; // TODO: 初始化为适当的值
            IntPtr ptrCB = new IntPtr(); // TODO: 初始化为适当的值
            IntPtr ptrState = new IntPtr(); // TODO: 初始化为适当的值
            bool expected = false; // TODO: 初始化为适当的值
            bool actual;
            actual = IOCompletionPort_Accessor.PostQueuedCompletionStatus( hIOCP, numBytesTransferred, ptrCB, ptrState );
            Assert.AreEqual( expected, actual );
            Assert.Inconclusive( "验证此测试方法的正确性。" );
        }

        /// <summary>
        ///GetStatus 的测试
        ///</summary>
        [TestMethod()]
        public void GetStatusTest()
        {
            int maxConcurrency = 0; // TODO: 初始化为适当的值
            IOCompletionPort target = new IOCompletionPort( maxConcurrency ); // TODO: 初始化为适当的值
            int iMilliseconds = 0; // TODO: 初始化为适当的值
            bool bTimedOut = false; // TODO: 初始化为适当的值
            bool bTimedOutExpected = false; // TODO: 初始化为适当的值
            WaitCallback waitCallback = null; // TODO: 初始化为适当的值
            WaitCallback waitCallbackExpected = null; // TODO: 初始化为适当的值
            object oState = null; // TODO: 初始化为适当的值
            object oStateExpected = null; // TODO: 初始化为适当的值
            target.GetStatus( iMilliseconds, out bTimedOut, out waitCallback, out oState );
            Assert.AreEqual( bTimedOutExpected, bTimedOut );
            Assert.AreEqual( waitCallbackExpected, waitCallback );
            Assert.AreEqual( oStateExpected, oState );
            Assert.Inconclusive( "无法验证不返回值的方法。" );
        }

        /// <summary>
        ///GetQueuedCompletionStatus 的测试
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Demo.Mmose.Core.dll" )]
        public void GetQueuedCompletionStatusTest()
        {
            SafeIOCompletionPortHandle_Accessor hIOCP = null; // TODO: 初始化为适当的值
            uint numBytesTransferred = 0; // TODO: 初始化为适当的值
            uint numBytesTransferredExpected = 0; // TODO: 初始化为适当的值
            IntPtr ptrCB = new IntPtr(); // TODO: 初始化为适当的值
            IntPtr ptrCBExpected = new IntPtr(); // TODO: 初始化为适当的值
            IntPtr ptrState = new IntPtr(); // TODO: 初始化为适当的值
            IntPtr ptrStateExpected = new IntPtr(); // TODO: 初始化为适当的值
            uint uiMilliseconds = 0; // TODO: 初始化为适当的值
            bool expected = false; // TODO: 初始化为适当的值
            bool actual;
            actual = IOCompletionPort_Accessor.GetQueuedCompletionStatus( hIOCP, out numBytesTransferred, out ptrCB, out ptrState, uiMilliseconds );
            Assert.AreEqual( numBytesTransferredExpected, numBytesTransferred );
            Assert.AreEqual( ptrCBExpected, ptrCB );
            Assert.AreEqual( ptrStateExpected, ptrState );
            Assert.AreEqual( expected, actual );
            Assert.Inconclusive( "验证此测试方法的正确性。" );
        }

        /// <summary>
        ///Dispose 的测试
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Demo.Mmose.Core.dll" )]
        public void DisposeTest1()
        {
            PrivateObject param0 = null; // TODO: 初始化为适当的值
            IOCompletionPort_Accessor target = new IOCompletionPort_Accessor( param0 ); // TODO: 初始化为适当的值
            bool disposing = false; // TODO: 初始化为适当的值
            target.Dispose( disposing );
            Assert.Inconclusive( "无法验证不返回值的方法。" );
        }

        /// <summary>
        ///Dispose 的测试
        ///</summary>
        [TestMethod()]
        public void DisposeTest()
        {
            int maxConcurrency = 0; // TODO: 初始化为适当的值
            IOCompletionPort target = new IOCompletionPort( maxConcurrency ); // TODO: 初始化为适当的值
            target.Dispose();
            Assert.Inconclusive( "无法验证不返回值的方法。" );
        }

        /// <summary>
        ///CreateIoCompletionPort 的测试
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Demo.Mmose.Core.dll" )]
        public void CreateIoCompletionPortTest1()
        {
            SafeFileHandle hFile = null; // TODO: 初始化为适当的值
            SafeIOCompletionPortHandle_Accessor hExistingIOCP = null; // TODO: 初始化为适当的值
            UIntPtr CompKey = new UIntPtr(); // TODO: 初始化为适当的值
            uint NumConcurrentThreads = 0; // TODO: 初始化为适当的值
            SafeIOCompletionPortHandle_Accessor expected = null; // TODO: 初始化为适当的值
            SafeIOCompletionPortHandle_Accessor actual;
            actual = IOCompletionPort_Accessor.CreateIoCompletionPort( hFile, hExistingIOCP, CompKey, NumConcurrentThreads );
            Assert.AreEqual( expected, actual );
            Assert.Inconclusive( "验证此测试方法的正确性。" );
        }

        /// <summary>
        ///CreateIoCompletionPort 的测试
        ///</summary>
        [TestMethod()]
        [DeploymentItem( "Demo.Mmose.Core.dll" )]
        public void CreateIoCompletionPortTest()
        {
            int numConcurrentThreads = 0; // TODO: 初始化为适当的值
            SafeIOCompletionPortHandle_Accessor expected = null; // TODO: 初始化为适当的值
            SafeIOCompletionPortHandle_Accessor actual;
            actual = IOCompletionPort_Accessor.CreateIoCompletionPort( numConcurrentThreads );
            Assert.AreEqual( expected, actual );
            Assert.Inconclusive( "验证此测试方法的正确性。" );
        }

        /// <summary>
        ///IOCompletionPort 构造函数 的测试
        ///</summary>
        [TestMethod()]
        public void IOCompletionPortConstructorTest()
        {
            int maxConcurrency = 0; // TODO: 初始化为适当的值
            IOCompletionPort target = new IOCompletionPort( maxConcurrency );
            Assert.Inconclusive( "TODO: 实现用来验证目标的代码" );
        }
    }
}
